#pragma once

CString douTostr( double dou )
{
	int decimal , sign, i;
	char *buffer = new char [10];
	char *buffer1 = new char [10] ;
	int precision = 10;
	int err;

	err = _ecvt_s( buffer, _CVTBUFSIZE, dou , precision , &decimal , & sign ) ;

	if ( decimal == 0 )
	{
		buffer1[0] = '0' ;
		buffer1[1] = '.' ;
		for ( int i = 2 ; i < 10 ; i ++ )
		{
			buffer1[i] = buffer[i-2] ;
		}
	}
	if ( decimal > 0 )
	{
		for ( i = 0 ; i < decimal ; i ++ )
		{
			buffer1[i] = buffer[i] ;
		}
		buffer1[i++] = '.' ;
		for ( ; i < 10 ; i ++ )
		{
			buffer1[i] = buffer[i-1] ;
		}
	}
	if ( decimal < 0 )
	{
		buffer1[0] = '0' ;
		buffer1[1] = '.' ;
		for ( i = 2 ; i < abs ( decimal ) + 2 ; i ++ )
		{
			buffer1[i] = '0' ;
		}
		int j = 0 ;
		for ( ; i < 10 ; i ++ )
		{
			buffer1[i] = buffer[j++] ;
		}
	}

	CString cstring ;

	if(dou<0)
		cstring = "-";
	for ( i = 0 ; i < 10 ; i ++ )
	{
		cstring = cstring + buffer1[i] ;
	}
	return cstring ;
}

